<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/view/include/taglib.jsp"%>
<html>
<head>
	<title>网站结构</title>
	<%@ include file="../../include/head.jsp"%>
    <link rel="stylesheet" href="${ctxStatic}/3rd-lib/jquery-ztree/3.5/css/zTreeStyle.css">
</head>
<body>
<div id="menu"><a href="javascript:;" title="刷新网站结构">${site.name}</a></div>
<ul id="tree" class="ztree"></ul>
<script src="${ctxStatic}/3rd-lib/jquery-ztree/3.5/js/jquery.ztree.core-3.5.min.js"></script>
<script>
    $(function () {
        var setting = {
            data: {
                simpleData: {
                    enable: true
                }
            },
            callback : {
                onClick : function(event, treeId, treeNode) {
                	if(treeNode.module=='nav'){
                		//导航模型
                		parent.frames['content'].location.href = "${ctx}/cms/category/list?siteId="+treeNode.siteId+"&parentId="+treeNode.id;
                	}else if(treeNode.module=='album'){
                		//相册模型
                		parent.frames['content'].location.href = "${ctx}/cms/album/list?categoryId="+treeNode.id;
                	}else if(treeNode.module=='link'){
                		//连接模型
                		parent.frames['content'].location.href = "${ctx}/cms/link/list?categoryId="+treeNode.id;
                	}else if(treeNode.module=='commodity'){
                		//商品模型
                		parent.frames['content'].location.href = "${ctx}/cms/commodity/list?categoryId="+treeNode.id;
                	}else{
                		//文章模型
                		parent.frames['content'].location.href = "${ctx}/cms/article/list?categoryId="+treeNode.id;
                	}
                }
            }
        };
        var zNodes =[
            <c:forEach items="${categoryList}" var="o" varStatus="status">
                { id:${o.id}, pId:${o.parentId}, name:"${o.name}", open:true,module:"${o.module}",siteId:${o.siteId}}<c:if test="${!status.last}">,</c:if>
            </c:forEach>
        ];
        $(document).ready(function(){
            var ztree = $.fn.zTree.init($("#tree"), setting, zNodes);
            ztree.expandAll(true);
            
            //点击网站
            $("#menu a").click(function(){
            	parent.frames['content'].location.href = "${ctx}/cms/category/list?siteId=${site.id}&parentId=0";
            });
        });
    });
</script>
</body>
</html>